//
//  KeyboardEmoticon.swift
//  CXSwiftWB
//
//  Created by meidaeriOS on 2017/6/7.
//  Copyright © 2017年 meidaer. All rights reserved.
//

import UIKit

class KeyboardEmoticon: NSObject {
    /// 当前组对应的文件夹名称
    var id: String?
    
    /// 当前表情对应的字符串
    var chs: String?
    
    /// 当前表情对应的图片
    var png: String? {
        didSet {
            let path = Bundle.main.path(forResource: id, ofType: nil, inDirectory: "Emoticons.bundle")!
            pngPath = (path as NSString).appendingPathComponent(png ?? "")
        }
    }
    
    /// 当前表情的绝对路径
    var pngPath: String?
    
    /// Emoji表情对应的字符串
    var code: String? {
        didSet {
            let scanner = Scanner(string: code ?? "")
            var result: UInt32 = 0
            scanner.scanHexInt32(&result)
            emoticonStr = "\(Character(UnicodeScalar(result)!))"
        }
    }
    
    /// 转换之后的emoji表情字符串
    var emoticonStr: String?
    
    /// 记录当前表情是否是删除按钮
    var isRemoveButton: Bool = false
    
    /// 记录当前表情的使用次数
    var count: Int = 0
    
    init(isRemoveButton: Bool)
    {
        self.isRemoveButton = isRemoveButton
    }
    
    init(dict: [String: AnyObject], id: String)
    {
        self.id = id
        super.init()
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
}
